package com.chen.springboot.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.chen.springboot.entity.Item;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;


public interface ItemMapper extends BaseMapper<Item> {
    
    @Update("update item set stock = stock - #{count} where id = #{itemId} and stock >= #{count}")
    int reduceStock(@Param("itemId") Long itemId, @Param("count") Integer count);
}
